
import unittest

from Schedule.Doctors import Doctors
from Schedule.CallCycleAndNumberCallsEvaluator import CallCycleAndNumberCallsEvaluator

class CallCycleAndNumberCallsEvaluatorTestCases(unittest.TestCase):
    def setUp(self):
        self._initCount = dict()
        for i in range(0, len (Doctors().doctorNames)):
            self._initCount[i] = 0;
    
    def tearDown(self):
        pass

    def ttest_1(self):

        callIndex = [0, 1, 5, 9, 12, 15, 18]
        
        callTally = []
        
        chromosome = [0, 
                      1, 2, 3, 4, 
                      2, 3, 4, 5, 
                      3, 4, 5, 
                      4, 5, 0, 
                      5, 0, 1, 
                      0] 
        
        score = CallCycleAndNumberCallsEvaluator(callIndex, callTally, self._initCount).evaluate(chromosome, False)
        
        self.assertEquals(score, 6)

    def ttest_2(self):

        callIndex = [0, 1, 5, 9, 12, 15]
        
        callTally = []
        
        chromosome = [0, 
                      1, 2, 3, 4, 
                      2, 3, 4, 5, 
                      3, 4, 5, 
                      4, 5, 0, 
                      5, 0, 1] 
        
        score = CallCycleAndNumberCallsEvaluator(callIndex, callTally, self._initCount).evaluate(chromosome, False)
        
        self.assertEquals(score, 6)

    def ttest_3(self):

        callIndex = [0, 1, 5, 9, 12, 15]
        
        callTally = []
        
        chromosome = [0, 
                      1, 2, 3, 4, 
                      0, 3, 4, 5, 
                      3, 4, 5, 
                      4, 5, 0, 
                      5, 0, 1] 
        
        score = CallCycleAndNumberCallsEvaluator(callIndex, callTally, self._initCount).evaluate(chromosome, False)
        
        self.assertEquals(score, 3)

    def test_4(self):

        callIndex = [0, 1, 5, 9, 12, 15, 18, 19, 20, 24, 28, 31]
        
        callTally = []
        
        chromosome = [0, 
                      1, 2, 3, 4, 
                      0, 3, 4, 5, 
                      3, 4, 5, 
                      4, 5, 0, 
                      5, 0, 1,
                      2,
                      1,
                      5, 3, 4, 0,
                      3, 4, 1, 0,
                      2, 1, 4,
                      4, 5, 3
                      ] 
        
        score = CallCycleAndNumberCallsEvaluator(callIndex, callTally, self._initCount).evaluate(chromosome, False)
        
        self.assertEquals(score, 11)

    def test_MinimumScore(self):

        callIndex = [0, 1, 5, 9, 12, 15, 18, 19, 20, 24, 28, 31]
        
        callTally = []
        
        chromosome = [0, 
                      0, 2, 3, 4, 
                      0, 3, 4, 5, 
                      0, 4, 5, 
                      0, 5, 0, 
                      0, 0, 1,
                      0,
                      0,
                      0, 3, 4, 0,
                      0, 4, 1, 0,
                      0, 1, 4,
                      0, 5, 3
                      ] 
        
        score = CallCycleAndNumberCallsEvaluator(callIndex, callTally, self._initCount).evaluate(chromosome, False)
        
        self.assertEquals(score, 0)

    def test_May2(self):

        callIndex = [0, 1, 5, 9, 12, 15, 18, 19, 20, 24, 28, 31, 34, 37, 38, 39, 43, 47, 50, 53, 56, 57, 58, 62, 66, 69, 72, 75, 76, 77, 78]
        
        callTally = []
        
        chromosome = [0, 4, 1, 3, 5, 5, 2, 1, 4, 3, 0, 2, 0, 2, 1, 3, 1, 1, 5, 2, 3, 1, 4, 0, 0, 1, 4, 2, 4, 2, 4, 5, 2, 4, 0, 3, 3, 1, 4, 5, 3, 0, 1, 1, 1, 4, 2, 1, 3, 5, 5, 3, 3, 2, 1, 3, 4, 1, 3, 1, 0, 5, 5, 2, 0, 4, 0, 1, 3, 2, 0, 3, 1, 5, 4, 2, 2, 3, 0, 5, 2, 1]
        
        score = CallCycleAndNumberCallsEvaluator(callIndex, callTally, self._initCount).evaluate(chromosome, False)
        
        self.assertEquals(score, 16)

        